package hashcodeandequals;

import java.io.*;

public class Bernard implements Serializable {
	private static final long serialVersionUID = 1L;

	public enum CoatType {
		smooth, rough
	}

	String name;
	int weight;
	CoatType coatType;

	public Bernard(String name, int weight, CoatType coatType) {
		this.name = name;
		this.weight = weight;
		this.coatType = coatType;
	}

	@Override
	public boolean equals(Object object) {
		if (object == null || !(object instanceof Bernard))
			return false;

		Bernard bernardCompare = (Bernard) object;

		if (bernardCompare.coatType.equals(this.coatType)
				&& bernardCompare.name.equals(this.name)
				&& bernardCompare.weight == this.weight)
			return true;
		else
			return false;

	}

	@Override
	public int hashCode() {
		return name.hashCode() + weight + coatType.ordinal();
	}
}
